package com.fuhe.chen.vendingmachine.service;

import com.alibaba.fastjson.JSONObject;
import com.fuhe.chen.vendingmachine.dto.BookOrderStatus;
import com.fuhe.chen.vendingmachine.dto.cond.BookOrderCond;
import com.fuhe.chen.vendingmachine.pojo.BookOrder;
import com.fuhe.chen.vendingmachine.pojo.RefundApply;
import com.github.pagehelper.PageInfo;

import java.util.List;

public interface IBookOrderService {

    /**
     * 添加预约订单
     * @param user_id
     * @param amount
     * @param machine_id
     * @param commodities
     */
    BookOrder addBookOrder(String user_id, Float amount, Integer machine_id,String comment,  List<JSONObject> commodities);

    /**
     * 根据用户id和订单状态查询订单列表
     * @param userId
     * @param status
     * @return
     */
    PageInfo<BookOrder> queryOrderByUserId(String userId, Integer status,String orderId, int pageNum, int pageSize);

    /**
     * 根据条件查询订单列表
     * @return
     */
    PageInfo<BookOrder> queryOrderByCondition(BookOrderCond cond,int pageNum,int pageSize);


    /**
     * 根据订单id查询订单信息
     * @param orderId
     * @return
     */
    BookOrder queryOrderByOrderId(String orderId);

    /**
     * 根据订单id查询订单信息(面向管理员)
     * @param orderId
     * @return
     */
    BookOrder queryOrderByOrderIdForAdmin(String orderId);


    /**
     * 预约订单付款
     * @param bookOrderId
     * @param pay_method
     * @param buyer_id
     * @param pay_order_id
     */
    void payBookOrder(String bookOrderId,Integer pay_method,String buyer_id,String pay_order_id);


    /**
     * 预约订单取货
     */
    void takeBookOrderCommodity(BookOrder bookOrder);

    /**
     * 预约订单进货
     */
    String addOrderCommodity(Integer machineID, String bookOrderID, String containerNumber);

    List<BookOrder> queryOrderByMachineId(int machineId);

    BookOrderStatus getBookOrderStatus(String userId);

    /**
     * 取消预约订单
     * @param book_order_id
     */
    String cancelBookOrder(String book_order_id);

    /**
     * 申请订单退款
     * @param bookOrderId
     */
    String applyForRefundBookOrder(String bookOrderId,String refund_reason);

    String cancelRefundBookOrder(String bookOrderId);

    PageInfo<RefundApply> queryBookOrderRefundApply(Integer pageNum, Integer pageSize);

    void approveRefund(String bookOrderId, Integer refundApplyId);

    String refuseRefund(String bookOrderId, Integer refundApplyId);

    String determineAddBookOrder(Integer machineID, String bookOrderID);

    void determinePickUpOrder(BookOrder bookOrder);

    BookOrder queryOrderByPickCode(Integer machineId, String pickCode);

    /**
     * 获取机器的已付款的预约订单数
     * @param machine_id
     */
    Integer getBookCapacity(Integer machine_id);
}
